//点击窗口得到x y坐标
import { ref,onMounted, onBeforeUnmount } from "vue";
export default function useXY(){


      const x=ref(0);
      const y=ref(0);

      const clickHandle=(e:any)=>{

        console.log(e.pageX);
        x.value=e.pageX;
        y.value=e.pageY;
        

      }
      onMounted(()=>{
        window.addEventListener("click",clickHandle);

      })
      onBeforeUnmount(()=>{

        window.removeEventListener("click",clickHandle); 

      })
      return {
        x,y
      }

  
 
}